package com.ushio.gougouwangguo.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public enum MaterialsTypeEnum {
    //资源收益
    RESOURCE_GAIN( 1,"获得"),
    //资源成本
    RESOURCE_COST( 2,"失去");

    private int type;
    private String typeName;

    // 构造函数 —— 必须是 private（省略 private 也可以）
    MaterialsTypeEnum(int type, String typeName) {
        this.type = type;
        this.typeName = typeName;
    }

    public int getType() {
        return type;
    }

    public String getTypeName() {
        return typeName;
    }

    // ✅ 转换成 List<Map> 方便返回前端
    public static List<Map<String, Object>> toList() {
        return Arrays.stream(values())
                .map(e -> {
                    Map<String, Object> map = new HashMap<>();
                    map.put("type", e.getType());
                    map.put("typeName", e.getTypeName());
                    return map;
                })
                .collect(Collectors.toList());
    }



}
